Plotly displays
In [1]:
import plotly as py
from plotly.tools import FigureFactory as FF
from plotly.graph_objs import graph_objs
py.offline.init_notebook_mode()
import numpy as np
from scipy.spatial import Delaunay
import Base as base
In [2]:
P = np.loadtxt( '../../examples/ex1/SharedVertexList.txt' );
tri = np.loadtxt( '../../examples/ex1/SharedTriList.txt', dtype=int );
nFaceLabels = np.loadtxt( '../../examples/ex1/FaceLabels.txt', dtype=int );
nType = np.loadtxt( '../../examples/ex1/NodeType.txt', dtype=int );
In [3]:
nFaceLabels = np.concatenate(
(
np.min( nFaceLabels, axis=1 ).reshape( -1, 1 ),
np.max( nFaceLabels, axis=1 ).reshape( -1, 1 )
), axis=1
)
nUniqFaceLabels = np.vstack( { tuple( row ) for row in nFaceLabels } );
nUniqueGrains = np.unique( nUniqFaceLabels )
print "Numbe rof unique grains = %d" % nUniqueGrains.size
In [7]:
# # pick one GB to plot
# n = 1986
# thisTri = tri[ np.where( base.ismember( nFaceLabels, nUniqFaceLabels[n].reshape( 1, -1 ), 'rows' )[0] )[0], : ].astype( int )
# print nUniqFaceLabels[n]
# print thisTri.shape
nGrain = 264
TheseFaces = np.where( np.any( nFaceLabels==nGrain, axis=1 ) )[0]
triThis = tri[ TheseFaces, : ]
faceThis = nFaceLabels[ TheseFaces, : ]
nP = np.unique( triThis )
triThis = np.array( base.ismember( triThis, nP )[1] ).reshape( -1, 3 )
myP = P[ list( nP ), :].T
In [5]:
# Example of what plotly can do
fig1 = FF.create_trisurf(x=myP[0], y=myP[1], z=myP[2],
simplices=triThis,
title="Example grain boundary",
aspectratio=dict(
x = np.ptp( myP[0] ),
y = np.ptp( myP[1] ),
z = np.ptp( myP[2] )
)
)
py.offline.iplot(fig1 )
In [10]:
np.savetxt( '../../examples/ex0/SharedVertexList.txt', myP.T, fmt='%f' )
np.savetxt( '../../examples/ex0/SharedTriList.txt', triThis, fmt='%d' )
np.savetxt( '../../examples/ex0/NodeType.txt', nType[ nP ], fmt='%d' )
np.savetxt( '../../examples/ex0/FaceLabels.txt', faceThis, fmt='%d' )